#pragma strict

var debrisSound : AudioClip;

private var debrisAudioSource : AudioSource;

function Awake (){
	debrisAudioSource = gameObject.AddComponent(AudioSource);
	debrisAudioSource.clip = debrisSound;
	debrisAudioSource.loop = false;
	debrisAudioSource.volume = 4;
	debrisAudioSource.playOnAwake = false;
}

function Start () {
	if(this.gameObject==null) return;
	Destroy(this.gameObject, 4);
}

function Update () {
}

function OnCollisionEnter (collision : Collision){
	//FIXME only when player gets destroyed comes a sound from scripts maybe because of time = 0 and the bullet dont moves further
	if(collision.gameObject.tag == "Tank" || collision.gameObject.tag == "Qube" || collision.gameObject.tag == "Pyramid" || collision.gameObject.tag == "Projectile"|| collision.gameObject.tag == "Scripts"){
//		Debug.Log("Projectile has a collision.");
		
		//TODO Projectile Explosion

		debrisAudioSource.Play();
		
	    Destroy(this.gameObject, 3);
	}
}